package com.wngbms;

import lombok.extern.slf4j.Slf4j;
import org.reactivestreams.Subscription;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * onNext
 * complete
 * onComplete
 *
 * subscribe
 * onSubscribe
 * onNext
 *
 */
@Slf4j
public class ReactorDemo {

    public static void main(String[] args) {

        Flux<String> seq1 = Flux.just("a", "b", "c", "d"); // FluxArray
//        List<String> list = Arrays.asList("f", "b", "a");
//        Flux<String> seq2 = Flux.fromIterable(list);

//        Mono<String> noData = Mono.empty();
//        Mono<String> data = Mono.just("f2");
//        data.subscribe();
//        Flux<Integer> nums = Flux.range(5, 3);

//        Disposable subscribe = seq1.subscribe();
//        subscribe.dispose();

        log.info("-----------------------------------");
        seq1.subscribe(x -> log.info("{}", x));



//        log.info("-----------------------------------");
//        seq1.subscribe(x -> log.info("{}",x),
//                e -> log.error("", e), () -> {
//                    log.info("complete consumer");
//                });
//
//        log.info("-----------------------------------");
//        seq1.subscribe(x -> log.info("{}", x),
//                e -> log.error("", e), () -> {
//                    log.info("complete consumer");
//                }, new Consumer<Subscription>() {
//                    @Override
//                    public void accept(Subscription subscription) {
//                        log.info("sub");
//                        subscription.request(999);
//                    }
//                });

    }

}
